Home:ALL Converter>AggressiveSplittingPlugin -> webpackJsonp is not defined

AggressiveSplittingPlugin -> webpackJsonp is not defined

Ask Time:2017-04-10T21:07:07         Author:Yuri Morozov

Json Formatter

With the transition to webpack2 for the sake of using AggressiveSplittingPlugin and speeding up the download of the bundle via HTTP/2, I ran into the problem of "Uncaught ReferenceError: webpackJsonp is not defined" when initializing each piece. Has anyone encountered such a thing and did you solve this problem somehow?

var path = require('path');
var webpack = require('webpack');
var ManifestPlugin = require('webpack-manifest-plugin');

module.exports = {
  devtool: 'source-map',
  entry: [
    path.join(__dirname, '../../js/main'),
    'jquery'
  ],
  output: {
    path: path.join(__dirname, '../../js/public'),
    filename: '[name].js',
    publicPath: '/assets/'
  },
  resolve: {
    alias: {'jquery': path.join(__dirname, '../../js/modules/libs/jquery-2.2.3.min.js')},
    extensions: ['.js', '.jsx'],
    modules: [
      path.resolve(path.join(__dirname, '../../js')),
      "node_modules"
    ],
  },
  plugins: [
    new webpack.optimize.OccurrenceOrderPlugin(true),
    new webpack.NoEmitOnErrorsPlugin(),
    new webpack.optimize.UglifyJsPlugin({
      output: {
        comments: false
      },
      compress: {
        warnings: false,
        // eslint-disable-next-line camelcase
        screw_ie8: true
      }
    }),
    new webpack.ProvidePlugin({
      jQuery: 'jquery',
      $: 'jquery',
      jquery: 'jquery'
    }),
    new webpack.optimize.AggressiveSplittingPlugin({
      minSize: 20000,
      maxSize: 50000
    }),
    new ManifestPlugin({
      fileName: 'manifest.json',
      basePath: 'js/public/'
    }),
  ],
  module: {
    rules: [
      {
        test: /\.js$/,
        use: [
          {
            loader: 'babel-loader'
          }
        ],
        include: path.join(__dirname, '../../js'),
        exclude: /node_modules/
      }
    ]
  }
};

Author:Yuri Morozov,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/43324014/aggressivesplittingplugin-webpackjsonp-is-not-defined
yy